#include <iostream>
#include <unordered_map>
using namespace std;

int arr[100] = { 5,6,8,6,9,1,6,1,2,4,9,1,9,8,2,3,6,4,7,7,5,9,5,0,3,8,7,5,8,1,5,8,6,1,8,3,0,3,7,9,2,
					 7,0,5,8,8,5,7,0,9,9,1,9,4,4,6,8,6,3,3,8,5,1,6,3,4,6,7,0,7,8,2,7,6,8,9,5,6,5,6,1,4,0,1,
					 0,0,9,4,8,0,9,1,2,8,5,0,2,5,3,3 };


int monthDay[13] = { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
unordered_map <string, int > hash;

int getMonthDay(int month)
{
	return monthDay[month];
}

void test()
{
	int num = 0;
	for (int i = 0; i < 100; i++)
	{
		if (arr[i] == 2)
		{
			for (int j = i + 1; i < 100; i++)
				if (arr[j] == 0)
				{
					for (int k = j + 1; k < 100; k++)
						if (arr[k] == 2)
						{
							for (int l = k + 1; l < 100; l++)
								if (arr[l] == 3)
								{
									for (int m = l + 1; m < 100; m++)
										for (int n = m + 1; n < 100; n++)
										{
											int month = arr[m] * 10 + arr[n];
											if ( month <= 12 && month >= 0)
											{
												for (int o = n + 1; o < 100; o++)
													for (int p = o + 1; p < 100; p++)
													{
														int day = arr[o] * 10 + arr[p];
														if (day >= 1 && day <= getMonthDay(m * 10 + n))
														{
															if (hash.count("%d%d",month, day)));
														}
													}
											}
										}
	
								}
						}
				}
		}

	}

	cout << hash.count();
}

int main()
{
	test();
	return 0;
}